package com.xiaomai.Action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ValueStack;
import com.xianrui.Util.CheckUtil;
import com.xianrui.email.EmailUtil;

public class EmailAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String email;
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String password;
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String Send() {
		String host= "smtp.aliyun.com";//
		String from= "xiaomai.com@aliyun.com";//发送人
		String to= getEmail();//收件人
		String subject= "傻晓的邮件";//主题
		String text= "验证码:666";//内容
		String senderUsername= "xiaomai.com@aliyun.com";
		String senderPassword= "xm196414";
		System.out.print("-------------:"+getEmail());
		boolean isEmail = CheckUtil.CheckEmail(getEmail());
		CheckUtil.CheckPassword(getPassword());
		ValueStack v=ActionContext.getContext().getValueStack();	
		if(!isEmail){
			v.setValue("#session.msg", "邮箱不正确");
			return "erorr__success";
		}
		if (EmailUtil.SendMail(host, from, to, subject, text, senderUsername, senderPassword)) {
			return "success";
		}
		v.setValue("#session.msg", "发送失败");
		return "erorr_success";
	}

}
